//
//  ListTableViewCell.m
//  SegmentDemo
//
//  Created by 塔兮 on 2022/4/11.
//

#import "ListTableViewCell.h"

@implementation ListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    self.backgroundColor = UIColorFromHex(@"FFFFFF");
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [self configureView];
    return self;
}

- (UIView *)line {
    if (!_line) {
        _line = [UIView new];
        _line.backgroundColor = UIColorFromHex(@"F5F5F5");
    }
    return _line;
}

- (UILabel *)name {
    if (!_name) {
        _name = [UILabel new];
        _name.font = FONT_BOLD_SIZE(14);
        _name.textColor = UIColorFromHex(@"000000");
        _name.backgroundColor = UIColorFromHex(@"FFFFFF");
    }
    return _name;
}

- (void)configureView {
    [self addSubview:self.name];
    [self addSubview:self.line];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(12);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(12);
        make.bottom.right.mas_equalTo(self);
        make.height.mas_offset(1);
    }];
}

- (void)setStringName:(NSString *)stringName {
    _stringName = stringName;
    self.name.text = stringName;
}

@end
